﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace WpfCommCtl.Controls
{
    /// <summary>
    /// button 拓展
    /// </summary>
    public static class ButtonExtensions
    {
        #region Icon text

        /// <summary>
        /// 文本图标依赖属性
        /// </summary>

        public static readonly DependencyProperty IconTextProperty = DependencyProperty.RegisterAttached(
            "IconText", typeof(string), typeof(ButtonExtensions), new PropertyMetadata(null));

        /// <summary>
        /// 设置Icon text
        /// </summary>
        /// <param name="element"> </param>
        /// <param name="value">   </param>
        public static void SetIconText(DependencyObject element, string value)
        {
            element.SetValue(IconTextProperty, value);
        }

        /// <summary>
        /// 获取icon text
        /// </summary>
        /// <param name="element"> </param>
        /// <returns> </returns>
        public static string GetIconText(DependencyObject element)
        {
            return (string)element.GetValue(IconTextProperty);
        }

        #endregion Icon text

        #region Icon Margin

        /// <summary>
        /// 设置 icon margin
        /// </summary>
        /// <param name="element"> </param>
        /// <param name="value">   </param>
        public static void SetIconMargin(DependencyObject element, Thickness value)
        {
            element.SetValue(IconMarginProperty, value);
        }

        /// <summary>
        /// 读取 icon margin
        /// </summary>
        /// <param name="element"> </param>
        /// <returns> </returns>
        public static Thickness GetIconMargin(DependencyObject element)
        {
            return (Thickness)element.GetValue(IconMarginProperty);
        }

        /// <summary>
        /// icom margin 依赖属性
        /// </summary>
        public static readonly DependencyProperty IconMarginProperty =
            DependencyProperty.RegisterAttached("IconMargin", typeof(Thickness), typeof(ButtonExtensions), new PropertyMetadata(new Thickness(0, 0, 0, 0)));

        #endregion Icon Margin

        #region IconVisibility

        /// <summary>
        /// set icon visibility
        /// </summary>
        /// <param name="element"> </param>
        /// <param name="value">   </param>
        public static void SetIconVisibility(DependencyObject element, Visibility value)
        {
            element.SetValue(IconVisibilityProperty, value);
        }

        /// <summary>
        /// get icon visibility
        /// </summary>
        /// <param name="element"> </param>
        /// <returns> </returns>
        public static Visibility GetIconVisibility(DependencyObject element)
        {
            return (Visibility)element.GetValue(IconVisibilityProperty);
        }

        /// <summary>
        /// icon visibility 依赖属性
        /// </summary>
        public static readonly DependencyProperty IconVisibilityProperty =
            DependencyProperty.RegisterAttached("IconVisibility", typeof(Visibility), typeof(ButtonExtensions), new PropertyMetadata(Visibility.Visible));

        #endregion IconVisibility

        #region TextVisibility

        /// <summary>
        /// set text visibility
        /// </summary>
        /// <param name="element"> </param>
        /// <param name="value">   </param>
        public static void SetTextVisibility(DependencyObject element, Visibility value)
        {
            element.SetValue(TextVisibilityProperty, value);
        }

        /// <summary>
        /// get text visibility
        /// </summary>
        /// <param name="element"> </param>
        /// <returns> </returns>
        public static Visibility GetTextVisibility(DependencyObject element)
        {
            return (Visibility)element.GetValue(TextVisibilityProperty);
        }

        /// <summary>
        /// text visibility 依赖属性
        /// </summary>
        public static readonly DependencyProperty TextVisibilityProperty =
            DependencyProperty.RegisterAttached("TextVisibility", typeof(Visibility), typeof(ButtonExtensions), new PropertyMetadata(Visibility.Visible));

        #endregion TextVisibility
    }
}